package com.umeox.watch.moto.gallery.ui.widget

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.widget.*
import com.umeox.watch.moto.gallery.R
import java.util.*

/**
 * Created by Rambo 2021/5/18
 * Describe:
 */
class ConfirmDialog(context: Context, titleString: String) :
    Dialog(context, R.style.CommonDialogTheme) {

    private lateinit var titleTv:TextView

    private var mTitle = titleString

    private var actionClickListener: ActionClickListener? = null

    interface ActionClickListener {
        fun onConfirm()
        fun onCancel()

    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        init()
    }

    fun setActionClickListener(listener: ActionClickListener) {
        actionClickListener = listener
    }

    private fun init() {
        setContentView(
            LayoutInflater.from(context).inflate(R.layout.dialog_delete, null)
        )

        findViewById<ImageView>(R.id.close_iv).setOnClickListener { dismiss() }
        findViewById<TextView>(R.id.ok_btn).setOnClickListener {
            actionClickListener!!.onConfirm()
            dismiss()
        }

        findViewById<TextView>(R.id.cancel_btn).setOnClickListener {
            actionClickListener!!.onCancel()
            dismiss()
        }

        titleTv = findViewById(R.id.title_tv)
        titleTv.text = mTitle


        val lp = window!!.attributes
        lp.width = 432
        lp.height = 284
        window!!.attributes = lp
    }

}